home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / sys / amiga / sksh / lnsoft next >
Encoding:
Text File  |  1994-09-02  |  1.5 KB  |  78 lines

  1. #!c:sksh
  2.  
  3. #*************************************************************************
  4. #
  5. # lnsoft - create a link or links
  6. #
  7. # Maurice LeBrun, 2/92.
  8. #
  9. # This function acts like the Unix "ln -s" command.
  10. # No flags are taken at present -- the default action of MakeLink is used.
  11. #
  12. # The HARD option is the default on the CBM version of MakeLink since 
  13. # it doesn't support softlinks in 2.04.  The version of MakeLink by
  14. # Stefan Becker make softlinks by default, and this works well on a
  15. # hard disk partition but not in ram:.
  16. #
  17. #*************************************************************************
  18.  
  19. if [ $# -lt 2 -o "$1" = '-?' ]
  20. then
  21.    echo 'Usage:' $(basename $0) 'files... target'
  22.    echo '       (links file or files to target)'
  23.    return 1
  24. fi
  25.  
  26. nloop = $(expr $# - 1)
  27. files = ""
  28. numloop i = 1 $nloop
  29. do
  30.     files = "$files $1"
  31.     shift
  32. done
  33.  
  34. # Set directory target flag.
  35.  
  36. target = $1
  37. if [ -d $target ] 
  38. then
  39.     isadir = 1
  40. else
  41.     isadir = 0
  42. fi
  43.  
  44. if [ $nloop -gt 1 -a ! $isadir = 1 ]
  45. then
  46.     echo 'Target not a directory!'
  47.     return 1
  48. fi
  49.  
  50. # handle directory name vs device name for target
  51.  
  52. if [ $isadir -eq 1 ]
  53. then
  54.     ltarget = $(expr length $target)
  55.     if [ $(expr substr $target $ltarget $ltarget) != ':' ]
  56.     then
  57.     target = "$target/"
  58.     fi
  59. fi
  60.  
  61. # loop over files
  62.  
  63. for file in $files
  64. do
  65.     if [ -f $file ]
  66.     then
  67.     filename = $(basename $file)
  68.     if [ $isadir -eq 1 ]
  69.     then
  70.         targetfile = $target$filename
  71.     else
  72.         targetfile = $target
  73.     fi
  74.     makelink $targetfile $file
  75.     fi
  76. done
  77. return 0
  78.